package Person.ith_28;

import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
public class CollectionDemo {
    public static void main(String[] args) {
        Collection<String> c = new ArrayList<String>();

        c.add("hello");
        c.add("world");
        c.add("jiahao");
        //Iterator<String> it = c.iterator(); 返回此集合中元素的迭代器，通过集合的iterator( )方法得到；
        Iterator<String> it = c.iterator();
/*
public Iterator<E> iterator() {
        return new Itr();
    }
    private class Itr implements Iterator<E> {

    }

* */

       while(it.hasNext()){
           // System.out.println(it.next());
       String s = it.next();
           System.out.println(s);
       }

    }
}
/*
*  c.add() 添加元素
* c.remove() 删除元素
* c.contains() 判断有无此元素
* c.isEmpty() 判断集合是否为空
* c.clear(); 清空内容
* c.size() 查询集合长度
*
* */